
#include "dock_commands.h"

DockCommandsTabsGalaxy::DockCommandsTabsGalaxy()
{
  this->zoomOut = new QPushButton(QIcon("../img/docks/zoom_out.png"), tr(""), this);
  this->zoomIn = new QPushButton(QIcon("../img/docks/zoom_in.png"), tr(""), this);
  this->zoomLayout.addWidget(this->zoomOut);
  this->zoomLayout.addWidget(this->zoomIn);
  
  this->left = new QPushButton(QIcon("../img/docks/left.png"), tr(""), this);
  this->right = new QPushButton(QIcon("../img/docks/right.png"), tr(""), this);
  this->up = new QPushButton(QIcon("../img/docks/up.png"), tr(""), this);
  this->down = new QPushButton(QIcon("../img/docks/down.png"), tr(""), this);
  this->reset = new QPushButton(QIcon("../img/docks/reset.png"), tr(""), this);
  this->rotateLayout.addWidget(this->up, 0, 1);
  this->rotateLayout.addWidget(this->left, 1, 0);
  this->rotateLayout.addWidget(this->reset, 1, 1);
  this->rotateLayout.addWidget(this->right, 1, 2);
  this->rotateLayout.addWidget(this->down, 2, 1);
  this->rotateLayout.addLayout(&this->zoomLayout, 3, 0, 1, 3);
  // checkbox
  this->showLinks = new QCheckBox(tr("Show links"), this);
  this->rotateLayout.addWidget(this->showLinks, 4, 0, 1, 3);
  this->showLinks->setCheckState(Qt::Checked);
  this->showSpaceShips = new QCheckBox(tr("Show space ships"), this);
  this->rotateLayout.addWidget(this->showSpaceShips, 5, 0, 1, 3);
  this->showSpaceShips->setCheckState(Qt::Checked);
  this->showSystemInfo = new QCheckBox(tr("Show star informations"), this);
  this->rotateLayout.addWidget(this->showSystemInfo, 6, 0, 1, 3);
  this->showSystemInfo->setCheckState(Qt::Checked);

  this->mainLayout.addLayout(&this->rotateLayout);
  
  this->mainLayout.setAlignment(Qt::AlignTop);
  this->setLayout(&this->mainLayout);
  
}

DockCommandsTabsGalaxy::~DockCommandsTabsGalaxy()
{
  delete(this->left);
  delete(this->right);
  delete(this->up);
  delete(this->down);
  delete(this->reset);
  delete(this->zoomIn);
  delete(this->zoomOut);
  delete(this->showLinks);
  delete(this->showSpaceShips);
  delete(this->showSystemInfo);
}

void		DockCommandsTabsGalaxy::setParent(QWidget *parent)
{
  this->parent = parent;
}

void		DockCommandsTabsGalaxy::setSignals()
{
  // signals connection
  connect(this->zoomOut, SIGNAL(pressed()), parent, SIGNAL(galaxyZoomOut()));
  connect(this->zoomIn, SIGNAL(pressed()), parent, SIGNAL(galaxyZoomIn()));
  connect(this->left, SIGNAL(pressed()), parent, SIGNAL(galaxyRotateLeft()));
  connect(this->right, SIGNAL(pressed()), parent, SIGNAL(galaxyRotateRight()));
  connect(this->up, SIGNAL(pressed()), parent, SIGNAL(galaxyRotateUp()));
  connect(this->down, SIGNAL(pressed()), parent, SIGNAL(galaxyRotateDown()));
  connect(this->reset, SIGNAL(pressed()), parent, SIGNAL(galaxyResetView()));

  connect(this->showLinks
	  , SIGNAL(stateChanged(int))
	  , parent
	  , SIGNAL(showLinks(int)));
  connect(this->showSpaceShips
	  , SIGNAL(stateChanged(int))
	  , parent
	  , SIGNAL(showSpaceShips(int)));
  connect(this->showSpaceShips
	  , SIGNAL(stateChanged(int))
	  , parent
	  , SIGNAL(showSystemInfo(int)));
}

DockCommandsTabs::DockCommandsTabs()
{
  this->galaxy.setParent(this);
  this->galaxy.setSignals();
  this->setTabPosition(QTabWidget::East);
  this->addTab(&this->galaxy, QIcon("../img/galaxy.png"), tr(""));
}

DockCommandsTabs::~DockCommandsTabs()
{

}

void		DockCommandsTabs::setParent(QWidget *parent)
{
  this->parent = parent;
}

DockCommands::DockCommands()
{
  this->tabs.setParent(this);
  this->setWidget(&this->tabs);
}

DockCommands::~DockCommands()
{
  
}

void		DockCommands::setParent(QWidget *parent)
{
  this->parent = parent;
}
